{% extends "templates/atnet_base.html" %}

{% block csslink %}
		{{ super() }}
<script src="/media/js/jquery.js"></script>

{% include 'templates/includes_datatable.html' %}
{% include 'templates/includes_jquery_ui.html' %}
<script src="/media/js/form_popup.js"></script>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
	var wasAction = false;
	
	$('#coowner-payments').dataTable({
		"bPaginate": false,
		"bLengthChange": false,
		"bFilter": true,
		"bSort": true,
		"bInfo": false,
		"bAutoWidth": false,
		"oLanguage": {
            "sUrl": "/media/js/dataTables.{{ app_user.lang }}.txt"
        },
		"bProcessing": true,
		"sAjaxSource": "{{ uri_for('vie_coowner_payments', imm_id=immeuble.key().id(), command='list_json') }}",
		"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
			$('td:eq(8)', nRow).html('<nodr><a class="edit" href="javascript:void(0);" id="' + aData[8] + '">{{ _("Edit") }}</a>  || <a class="commit" href="javascript:void(0);" id="' + aData[8] + '">{{ _("Commit check") }}</a>|| <a class="commit" href="javascript:void(0);" id="' + aData[8] + '">{{ _("Commit payment") }}</a></nobr>');
		},
	});
	
	$('#add-cp').live('click', function(){
		$(this).LaunchPopup(
			{
				TableId: '#coowner-payments',
				DivId: '#dialog-form',
				FormId: '#generated-form',
				UrlForm: "{{ uri_for('vie_coowner_payments', imm_id=immeuble.key().id(), command='add') }}",
				Mode: 'add',
				Title: '{{ _("Add coowner payment") }}'
			}
		)
	});
	
	$('#coowner-payments tbody tr a').live('click', function(e) {
		if ($(this).attr('class') == 'edit') {
		$(this).LaunchPopup(
				{
					TableId: '#coowner-payments',
					DivId: '#dialog-form',
					FormId: '#generated-form',
					UrlForm: "{{ uri_for('vie_coowner_payments', imm_id=immeuble.key().id(), command='edit') }}" + e.target.id + "/",
					Mode: 'edit',
					Title: '{{ _("Edit coowner payment") }}',
					UrlReturn: "{{ uri_for('fundraising', imm_id=immeuble.key().id(), command='list') }}"
				}
			)
		}
		if ($(this).attr('class') == 'commit') {
			$(this).LaunchPopup(
					{
						TableId: '#coowner-payments',
						DivId: '#dialog-form',
						FormId: '#generated-form',
						UrlForm: "{{ uri_for('vie_coowner_payments', imm_id=immeuble.key().id(), command='commit') }}" + e.target.id + "/",
						Mode: 'edit',
						Title: '{{ _("Commit coowner payment") }}',
						UrlReturn: "{{ uri_for('fundraising', imm_id=immeuble.key().id(), command='list') }}"
					}
				)
			}
	});

	
});
</script>
{% endblock %}

{% block title %} 
	{{ title }}
{% endblock %}

{% block header %}
{{ header }}
{% endblock %}

{% block login%}
{% if show_login %}
{{ super() }}
{% endif %}
{% endblock%}

{% block navigation %}
{% if not show_login %}
{{ super() }}
{% endif %}
{% endblock %}

{% block section_menu %}
{% include 'templates/includes_vie_de_la_copropriete.html' %}
{% endblock %}

{% block main_content %}
<p>
	<!-- <p><a href="javascript:void(0);" id="add-cp">{{ _('Add coowner payment') }}</a></p>  -->
	<div id="demo">
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="coowner-payments" width="100%">
		<thead>
			<tr>
				<th>{{ _(fields.fundrising) }}</th>
				<th>{{ _(fields.coowner) }}</th>
				<th>{{ _(fields.type) }}</th>
				<th>{{ _(fields.cheque_date) }}</th>
				<th>{{ _(fields.payment_num) }}</th>
				<th>{{ _(fields.bank_date) }}</th>
				<th>{{ _(fields.amount) }}</th>
				<th>{{ _(fields.money_recived) }}</th>
				<th width="20"></th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td colspan="7" class="dataTables_empty">{{ _('Loading data from server') }}</td>
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<th>{{ _(fields.fundrising) }}</th>
				<th>{{ _(fields.coowner) }}</th>
				<th>{{ _(fields.type) }}</th>
				<th>{{ _(fields.cheque_date) }}</th>
				<th>{{ _(fields.payment_num) }}</th>
				<th>{{ _(fields.bank_date) }}</th>
				<th>{{ _(fields.amount) }}</th>
				<th>{{ _(fields.money_recived) }}</th>
				<th width="20"></th>
			</tr>
		</tfoot>
	</table>
	</div>
	{% include 'templates/includes_popup_form.html' %}
</p>
<script>
	$(function() {
		var user_lang = "{{ app_user.lang }}";
		if (user_lang == "en") { user_lang = "en-GB"};
		$.datepicker.setDefaults( $.datepicker.regional[ user_lang ] );
		
		$("#cheque_date").live("focus", function() {
		    $(this).datepicker({
		        inline: true,
		    });
		});
		$("#bank_date").live("focus", function() {
			$(this).datepicker({
			    inline: true,
			});
		});
	});
</script>			
{% endblock %}
